package com.yanqu.road.server.manger.config.grandchild.talent.enums;

import com.yanqu.road.server.manger.config.grandchild.talent.condition.ITalentCondition;
import com.yanqu.road.server.manger.config.grandchild.talent.condition.TalentConditionNOCOND;
import com.yanqu.road.server.manger.config.grandchild.talent.condition.TalentConditionQUA;
import com.yanqu.road.server.manger.config.grandchild.talent.condition.TalentConditionTAA;
import com.yanqu.road.server.manger.config.grandchild.talent.entity.TalentConditionParam;
import com.yanqu.road.server.manger.config.grandchild.talent.entity.TalentConditionResult;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * 前提随机条件
 */
public enum eGrandChildTalentCondition {

    NOCOND("NOCOND", new TalentConditionNOCOND()), // 【无条件】

    QUA("QUA", new TalentConditionQUA()), // 资质

    TAA("TAA", new TalentConditionTAA()), // 孙子总天资

    ;

    private static Map<String, ITalentCondition> cacheMap = new ConcurrentHashMap<>();

    static {
        for (eGrandChildTalentCondition value : values()) {
            cacheMap.put(value.name, value.condition);
        }
    }

    private String name;
    private ITalentCondition condition;

    eGrandChildTalentCondition(String name, ITalentCondition condition) {
        this.name = name;
        this.condition = condition;
    }

    public static TalentConditionResult getResult(TalentConditionParam param) {
        ITalentCondition condition = cacheMap.get(param.getCondition().getName());
        return condition.getResult(param);
    }

}
